﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using System;

namespace Ausy.Silverlight.Survey.QuestionModule.Model
{
    /// <summary>
    /// Cette classe représente une Question
    /// </summary>
    public class Question
    {
        #region Identifier Property

        /// <summary>
        /// Identifiant du Questionnaire
        /// </summary>
        public Guid Identifier { get; set; }

        #endregion        

        #region Text Property
        /// <summary>
        /// Property text
        /// </summary>
        private string text;

        /// <summary>
        /// Property Text
        /// </summary>
        public string Text
        {
            get { return this.text; }
            set { this.text = value; }
        }
        #endregion

        #region AnswerCollection Property
        /// <summary>
        /// Property answerCollection
        /// </summary>
        private Collection<Answer> answerCollection;

        /// <summary>
        /// Property AnswerCollection
        /// </summary>
        public IEnumerable<Answer> AnswerCollection
        {
            get { return this.answerCollection; }
        }
        #endregion

        #region Constructors

        /// <summary>
        /// Constructeur par défaut
        /// </summary>
        public Question()
        {
            this.Identifier = Guid.Empty;
            this.text = string.Empty;
            this.answerCollection = new Collection<Answer>();
        }

        /// <summary>
        /// Constructeur par text et réponses
        /// </summary>
        /// <param name="text">text de la question</param>
        /// <param name="answers">Réponses associés</param>
        public Question(Guid identifier, string text, IEnumerable<Answer> answers)
            : this()
        {
            this.Identifier = identifier;
            this.text = text;
            foreach (var item in answers)
            {
                this.answerCollection.Add(item);
            }
        }
        #endregion
    }
}
